package com.team.kaidb.model.impl;

import com.android.volley.Request;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.team.kaidb.app.KDBApplication;
import com.team.kaidb.bean.request.IRequestBean;
import com.team.kaidb.bean.request.LoginRequestBean;
import com.team.kaidb.model.IModelLoginData;
import com.team.kaidb.presenter.OnLoginDataListener;
import com.team.kaidb.utils.DomainManager;
import com.team.kaidb.utils.volley.VolleryRequest;

/**
 * Created by maizi on 15/6/27.
 */
public class ModelLoginDataImpl implements IModelLoginData{
    @Override
    public void getLoginData(IRequestBean bean,final OnLoginDataListener listener) {

        if (KDBApplication.noHttpTest){
            listener.onLoadSuccess("success");
        }else{
            //这里是访问网络的地方
            VolleryRequest.getInstance().newStringRequest(Request.Method.POST, DomainManager.getInstance().getLoginUrl(bean), new Response.Listener<String>() {
                @Override
                public void onResponse(String response) {
                    listener.onLoadSuccess(response);
                }
            }, new Response.ErrorListener() {
                @Override
                public void onErrorResponse(VolleyError error) {
                    listener.onLoadFaild(error);
                }
            });

        }
    }

}
